package cn.sciento.transfer.infra.datasource.ddl.sqlserver.dto;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.util.CollectionUtils;

public class ColumnEntity {
  public static final String COLUMN_NAME = "column_name";
  
  public static final String COLUMN_COMMENT = "column_comment";
  
  public static final String COLUMN_TYPE = "column_type";
  
  public static final String COLUMN_SIZE = "column_size";
  
  public static final String COLUMN_DEFAULT = "column_default";
  
  public static final String IS_NULL_ABLE = "is_null_able";
  
  public static final String IS_IDENTITY = "is_identity";
  
  private String columnName;
  
  private String columnComment;
  
  private String columnType;
  
  private Integer columnSize;
  
  private String columnDefault;
  
  private Integer isNullAble;
  
  private Integer isIdentity;
  
  public static List<ColumnEntity> build(List<Map<String, Object>> columMapList) {
    List<ColumnEntity> columnEntityList = new ArrayList<>();
    if (CollectionUtils.isEmpty(columMapList)) {
      return columnEntityList;
    }
    for (Map<String, Object> columMap : columMapList) {
      ColumnEntity columnEntity = new ColumnEntity();
      columnEntity.setColumnName((String)columMap.get("column_name"));
      columnEntity.setColumnComment((String)columMap.get("column_comment"));
      columnEntity.setColumnType((String)columMap.get("column_type"));
      columnEntity.setColumnSize(Integer.valueOf(Integer.parseInt(columMap.get("column_size").toString())));
      columnEntity.setColumnDefault((String)columMap.get("column_default"));
      columnEntity.setIsNullAble((Integer)columMap.get("is_null_able"));
      columnEntity.setIsIdentity((Integer)columMap.get("is_identity"));
      columnEntityList.add(columnEntity);
    } 
    return columnEntityList;
  }
  
  public String getColumnName() {
    return this.columnName;
  }
  
  public void setColumnName(String columnName) {
    this.columnName = columnName;
  }
  
  public String getColumnComment() {
    return this.columnComment;
  }
  
  public void setColumnComment(String columnComment) {
    this.columnComment = columnComment;
  }
  
  public String getColumnType() {
    return this.columnType;
  }
  
  public void setColumnType(String columnType) {
    this.columnType = columnType;
  }
  
  public Integer getColumnSize() {
    return this.columnSize;
  }
  
  public void setColumnSize(Integer columnSize) {
    this.columnSize = columnSize;
  }
  
  public String getColumnDefault() {
    return this.columnDefault;
  }
  
  public void setColumnDefault(String columnDefault) {
    this.columnDefault = columnDefault;
  }
  
  public Integer getIsNullAble() {
    return this.isNullAble;
  }
  
  public void setIsNullAble(Integer isNullAble) {
    this.isNullAble = isNullAble;
  }
  
  public Integer getIsIdentity() {
    return this.isIdentity;
  }
  
  public void setIsIdentity(Integer isIdentity) {
    this.isIdentity = isIdentity;
  }
}
